
package GCJ2009.Round1C;

import java.io.*;
import java.util.*;

public class Bribe_the_Prisoners {

    BufferedReader fin;
    PrintWriter fout;

    void openFiles() throws IOException {
        fin = new BufferedReader(new FileReader("Bribe_the_Prisoners.in"));
        fout = new PrintWriter(new BufferedWriter(new FileWriter("Bribe_the_Prisoners.out")));
    }

    void closeFiles() throws IOException {
        fin.close();
        fout.close();
    }

    int P, Q;
    int[] r, order;
    boolean[] fre;
    boolean[] cell;
    int result = 1000000000;

    void input() throws IOException {
        String s = fin.readLine();
        StringTokenizer ss = new StringTokenizer(s);
        P = Integer.parseInt(ss.nextToken());
        Q = Integer.parseInt(ss.nextToken());

        r = new int[Q];
        fre = new boolean[Q];
        order = new int[Q];
        
        s = fin.readLine();
        ss = new StringTokenizer(s);
        for (int i = 0; i < Q; i++)
            r[i] = Integer.parseInt(ss.nextToken());
    }

    void attempt(int k)
    {
        if (k == Q)
        {
            cell = new boolean[P];
            for (int i = 0; i < Q; i++)
            {
                cell[order[i]] = false;

                int left = order[i]-1;
                while ((left >= 0) && (cell[left])) left--;

                int right = order[i]-1;
                while ((right <= P-1) && (cell[right])) right++;

                // count += order[i]-1 - left + right - order[i];
            }
        }

        for (int i = 0; i < Q; i++)
            if (fre[i])
            {
                fre[i] = false;
                order[k] = r[i];
                attempt(k+1);
                fre[i] = true;
            }
    }

    void process() {
        for (int i = 0; i < Q; i++) fre[i] = true;
        attempt(0);
    }

    void output() {
    }

    void takeTest() throws IOException {
        int nTest = Integer.parseInt(fin.readLine());
        for (int test = 1; test <= nTest; test++)
        {
            input();
            process();
            fout.print("Case #" + test + ": ");
            output();
        }
    }
    public static void main(String[] args) throws IOException {
        Bribe_the_Prisoners myProgram = new Bribe_the_Prisoners();

        myProgram.openFiles();
        myProgram.takeTest();
        myProgram.closeFiles();
    }
}